package com.value.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class mysql {
	//private static final String url = "jdbc:mysql://localhost:3306/tyds";
	//private static final String dbUser = "root";
  //	private static final String dbPwd = "2014121146";
	private static String url = "jdbc:mysql://localhost:3306/tyds?"	+ "user=root&password=2014121146&useUnicode=true&characterEncoding=UTF-8";
	private static String driverClass = "com.mysql.jdbc.Driver";
	static{
		
		try {
			Class.forName(driverClass);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static Connection getConnection(){
		try {
		//	Connection conn = DriverManager.getConnection(url,dbUser,dbPwd);
			Connection conn = DriverManager.getConnection(url);
			return conn;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}
	public static void release(Connection connection,Statement statement,ResultSet rs){
		try {
			if (rs!=null) {
				rs.close();
			}
			if (statement!=null) {
				statement.close();
			}
			if (connection!=null) {
				connection.close();
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

